<ui:composition template="/WEB-INF/templates/main-template.xhtml" 
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" >
	
	<ui:param name="pageName" value="Raise Asset Request" />
	
	<ui:define name="sidebar">
		<ui:include src="/WEB-INF/templates/public-sidebar.xhtml"/>
	</ui:define>
	<ui:define name="content">
		
		<h:outputText value="Asset Request Form" styleClass="outputTextTitle"/>	
		<h:form> 
		 <p:growl/>
		 
		  <p:tabView id="Table" > 
				
				<p:tab id="tab1" title="Create Asset Request" >
		 
		   <h:outputLabel value="Employee Details" style="font-weight:bold;color: #00A2DE;"/>
		   <h:panelGrid columns="6" style="width: 80%" cellspacing="8" columnClasses="employeeDetailLabel,gridCellMiddleLeftAligned, employeeDetailText, employeeDetailLabel,gridCellMiddleLeftAligned, employeeDetailText">
 
           <h:outputLabel value="Asset Code" />
           <h:outputLabel value=":" />
           <h:outputText value="#{raiseAssetRequestBean.assetRequest.assetReferenceCode}" />
                      
           <h:outputLabel value="Request Date" />
           <h:outputLabel value=":" />
           <h:outputText value="#{raiseAssetRequestBean.date}" >
           		<f:convertDateTime pattern="dd-MMM-yyyy HH:mm a" timeZone="#{raiseAssetRequestBean.timeZone}"/> 
           </h:outputText>
       
           <h:outputLabel value="Employee Name " />
           <h:outputLabel value=":" />
           <h:outputText value="#{raiseAssetRequestBean.wamUser.employee.firstName} #{raiseAssetRequestBean.wamUser.employee.lastName}" />

           <h:outputLabel value="Recommended By" />
           <h:outputLabel value=":" />
           <h:outputText value="#{raiseAssetRequestBean.assetRequest.recommendedBy.firstName} #{raiseAssetRequestBean.assetRequest.recommendedBy.lastName}" />

           <h:outputLabel value="Approved By " />
           <h:outputLabel value=":" />
           <h:outputText value="#{raiseAssetRequestBean.assetRequest.approvedBy.firstName} #{raiseAssetRequestBean.assetRequest.approvedBy.lastName}"  />
           
          </h:panelGrid>
          
          
          <h:outputLabel value="Asset Details" style="font-weight:bold;color: #00A2DE;"/>
           <h:panelGrid columns="6"  cellspacing="8" columnClasses="gridCellMiddleLeftAligned,employeeDetailLabel,gridCellMiddleLeftAligned, employeeDetailLabel">
                           
	             
	             <h:panelGroup>
	             	<h:outputLabel value="*" style="color : red;font-weight:bold;float:left;"/>
	             	<h:outputText value="Asset Type" style="font-weight:bold;float:left;"/>
	            	<h:outputText value=":" style="font-weight:bold;float:left;"/>
	             </h:panelGroup>
	             
	             <h:panelGroup>
	             	<h:outputLabel value="*" style="color : red;font-weight:bold;float:left;"/>
	             	<h:outputText value="Required On" style="font-weight:bold;float:left;"/>
	             	<h:outputText value=":" style="font-weight:bold;float:left;"/>
	             </h:panelGroup>
	             
	             <h:panelGroup>
	             	<h:outputLabel value="*" style="color : red;font-weight:bold;float:left;"/>
	             	<h:outputText value="Expected Return Date" style="font-weight:bold;float:left;"/>
	             	<h:outputText value=":" style="font-weight:bold;float:left;"/>
	             </h:panelGroup>
	             
	             <h:panelGroup>
	             	<h:outputLabel value="*" style="color : red;font-weight:bold;float:left;"/>
	             	<h:outputText value="Purpose" style="font-weight:bold;float:left;"/>
	             	<h:outputText value=":" style="font-weight:bold;float:left;" />
	             </h:panelGroup>
	             
	             <h:panelGroup>
	             	<h:inputHidden/>
	             	<h:outputText value="Remarks" style="font-weight:bold;float:left;"/>
	             	<h:outputText value=":" style="font-weight:bold;float:left;"/>
	             </h:panelGroup>
	             
	             <h:inputHidden/>
	             
	             
	             
	             <p:selectOneMenu value="#{raiseAssetRequestBean.assetDetails.assetType}" style="width: 160px;">
		              <f:selectItems value="#{raiseAssetRequestBean.assetsMap}" />
	             </p:selectOneMenu>
	             
	             
	             <p:calendar  pattern="dd-MMM-yyyy" value="#{raiseAssetRequestBean.assetDetails.requiredDate}" showButtonPanel="true" navigator="true" yearRange="c:c+10"/>
	             
	             
	             <p:calendar pattern="dd-MMM-yyyy" value="#{raiseAssetRequestBean.assetDetails.expectedReturnDate}" showButtonPanel="true" navigator="true" yearRange="c:c+10"/>
	              
	             
	             <p:selectOneMenu value="#{raiseAssetRequestBean.assetDetails.purpose}" style="width:100px;" >  
					<f:selectItems value="#{raiseAssetRequestBean.assetPurposeMap}" />   
	             </p:selectOneMenu>
	              
	             
	             <p:inputTextarea value="#{raiseAssetRequestBean.assetDetails.remarks}" rows="2" autoResize="false" />
	             
	             
	             <h:panelGroup>
	                <p:commandButton value="Add" action="#{raiseAssetRequestBean.addAssetDetailsAction}" update="@form" style="width:62px;"/>                  
	                
	             </h:panelGroup> 
           </h:panelGrid>
           
           <p:dataTable  value="#{raiseAssetRequestBean.assetDetailsList}" var="newAsset"  binding="#{raiseAssetRequestBean.assetDetailsTable}">   
  
		            <p:column headerText="Asset Type"> 
		              	<h:outputText value="#{newAsset.assetType}" />                 
		            </p:column>  
		  
		            <p:column headerText="Required On"> 
		              	<h:outputText value="#{newAsset.requiredDate}"  > 
		              		<f:convertDateTime pattern="dd-MMM-yyyy" timeZone="#{raiseAssetRequestBean.timeZone}"/>
		              	</h:outputText> 	               
		            </p:column>  
		            
		            <p:column headerText="Return Date"> 
		              	<h:outputText value="#{newAsset.expectedReturnDate}" >
		              		<f:convertDateTime pattern="dd-MMM-yyyy" timeZone="#{raiseAssetRequestBean.timeZone}"/>
		              	</h:outputText>                  
		            </p:column>  
		            
		            <p:column headerText="Purpose"> 
		              	<h:outputText value="#{newAsset.purpose}" />  	               
		            </p:column>  
		            
		            <p:column headerText="Remarks"> 
		              	<h:outputText value="#{newAsset.remarks}" />                 
		            </p:column>  
			        
					<p:column headerText="Delete" style="text-align: center; width: 30px;">		
						<p:commandButton icon="ui-icon-close" title="Remove from list"
							actionListener="#{raiseAssetRequestBean.removeAssetDetailsAction}" style="padding: 0" update="@form" />	
					</p:column>  
          </p:dataTable>
          
          
        <h:panelGrid style="padding-top: 5px; width: 100%; border-top: 1px solid #d9d9d9"
						columnClasses="gridCellMiddleRightAligned">
			  <h:panelGroup>
		           <p:commandButton id="submit" value="Submit" update="@form"  actionListener="#{raiseAssetRequestBean.confirmationAction}"  />
		           <p:commandButton value="Home" action="wudashboard" /> 		           
	          </h:panelGroup>
		</h:panelGrid>
		</p:tab>
		
		<p:tab id="tab2" title="Edit Asset Request"> 
			<p:dataTable  value="#{raiseAssetRequestBean.viewAssetRequestList}" var="editAsset" paginator="true" rows="20" >   
  
		           <p:column headerText="S.No"> 
		              	<h:outputText value="#{editAsset.sno}" />                 
		            </p:column>
		           
		            <p:column headerText="Asset Code"> 
		              	<h:outputText value="#{editAsset.assetReferenceCode}" />                 
		            </p:column>  
		  		            
		            <p:column headerText="Request Date"> 
		              	<h:outputText value="#{editAsset.requestDate}" >
		              		<f:convertDateTime pattern="dd-MMM-yyyy" timeZone="#{raiseAssetRequestBean.timeZone}"/>
		              	</h:outputText>                  
		            </p:column>  
		            
		            <p:column headerText="Recommender Status"> 
		              	<h:outputText value="#{editAsset.recommenderStatus}" />  	               
		            </p:column>  
		            
		            <p:column headerText="Approver Status"> 
		              	<h:outputText value="#{editAsset.approverStatus}" />                 
		            </p:column>  
			        
					<p:column headerText="Edit" style="text-align: center; width: 30px;">		
						 <p:commandButton action="#{raiseAssetRequestBean.editAssetRequestAction}" value="View" update="@form" disabled="#{editAsset.approverStatus eq 'APPROVED'}">			
							<f:param id="editAssetCode" name="editAssetCode" value="#{editAsset.assetReferenceCode}" />
						 </p:commandButton>
					</p:column>  
            </p:dataTable>
		</p:tab>
		
		<p:tab id="tab3" title="View Asset Request"> 
			<p:dataTable  value="#{raiseAssetRequestBean.viewAssetRequestList}" var="viewAsset" paginator="true" rows="20" >   
  
		           <p:column headerText="S.No"> 
		              	<h:outputText value="#{viewAsset.sno}" />                 
		            </p:column>
		           
		            <p:column headerText="Asset Code"> 
		              	<h:outputText value="#{viewAsset.assetReferenceCode}" />                 
		            </p:column>  
		  		            
		            <p:column headerText="Request Date"> 
		              	<h:outputText value="#{viewAsset.requestDate}" >
		              		<f:convertDateTime pattern="dd-MMM-yyyy" timeZone="#{raiseAssetRequestBean.timeZone}"/>
		              	</h:outputText>                  
		            </p:column>  
		            
		            <p:column headerText="Recommender Status"> 
		              	<h:outputText value="#{viewAsset.recommenderStatus}" />  	               
		            </p:column>  
		            
		            <p:column headerText="Approver Status"> 
		              	<h:outputText value="#{viewAsset.approverStatus}" />                 
		            </p:column>  
			        
					<p:column headerText="View/Print" style="text-align: center; width: 30px;">		
						 <p:commandButton action="#{raiseAssetRequestBean.viewOrPrintAssetRequestAction}" value="View" update="@form">			
							<f:param id="assetCode" name="assetCode" value="#{viewAsset.assetReferenceCode}" />
						 </p:commandButton>
					</p:column>  
            </p:dataTable>
		</p:tab>
		</p:tabView>
		
	<p:dialog hideEffect="fade" showEffect="fade" 
				header="Edit Asset Request Details "
				id="assetEditDialog" widgetVar="assetEditDialog" resizable="false"
				modal="true" >
		 		
		 <h:outputLabel value="Employee Details" style="font-weight:bold;color: #00A2DE;"/>
		 <h:panelGrid columns="6" cellspacing="8" columnClasses="employeeDetailLabel,gridCellMiddleLeftAligned, employeeDetailText, employeeDetailLabel,gridCellMiddleLeftAligned, employeeDetailText" >
		          
           <h:outputLabel value="Asset Code" />
           <h:outputLabel value=":" />
           <h:outputText value="#{raiseAssetRequestBean.editAssetRequest.assetReferenceCode}" />
           
           <h:outputLabel value="Request Date" />
           <h:outputLabel value=":" />
           <h:outputText value="#{raiseAssetRequestBean.editAssetRequest.requestDate}" >
           		<f:convertDateTime pattern="dd-MMM-yyyy HH:mm a" timeZone="#{raiseAssetRequestBean.timeZone}"/> 
           </h:outputText>

           <h:outputLabel value="Employee Name " />
           <h:outputLabel value=":" />
           <h:outputText value="#{raiseAssetRequestBean.editAssetRequest.employee.firstName} #{raiseAssetRequestBean.editAssetRequest.employee.lastName}" />
           
           <h:outputLabel value="Module Name " />
           <h:outputLabel value=":" />
           <h:outputText value="#{raiseAssetRequestBean.editAssetRequest.employee.moduleName}" />
		              
           <h:outputLabel value="Recommended By" />
           <h:outputLabel value=":" />
           <h:outputText value="#{raiseAssetRequestBean.editAssetRequest.recommendedBy.firstName} #{raiseAssetRequestBean.editAssetRequest.recommendedBy.lastName}" />

           <h:outputLabel value="Approved By " />
           <h:outputLabel value=":" />
           <h:outputText value="#{raiseAssetRequestBean.editAssetRequest.approvedBy.firstName} #{raiseAssetRequestBean.editAssetRequest.approvedBy.lastName}"  />
           
          
          </h:panelGrid> 
           
          <h:outputLabel value="Asset Details" style="font-weight:bold;color: #00A2DE;"/>
           <h:panelGrid id="dialogGrid" columns="6"  cellspacing="8" columnClasses="gridCellMiddleLeftAligned,employeeDetailLabel,gridCellMiddleLeftAligned, employeeDetailLabel">
                           
	             
	             <h:panelGroup>
	             	<h:outputLabel value="*" style="color : red;font-weight:bold;float:left;"/>
	             	<h:outputText value="Asset Type" style="font-weight:bold;float:left;"/>
	            	<h:outputText value=":" style="font-weight:bold;float:left;"/>
	             </h:panelGroup>
	             
	             <h:panelGroup>
	             	<h:outputLabel value="*" style="color : red;font-weight:bold;float:left;"/>
	             	<h:outputText value="Required On" style="font-weight:bold;float:left;"/>
	             	<h:outputText value=":" style="font-weight:bold;float:left;"/>
	             </h:panelGroup>
	             
	             <h:panelGroup>
	             	<h:outputLabel value="*" style="color : red;font-weight:bold;float:left;"/>
	             	<h:outputText value="Expected Return Date" style="font-weight:bold;float:left;"/>
	             	<h:outputText value=":" style="font-weight:bold;float:left;"/>
	             </h:panelGroup>
	             
	             <h:panelGroup>
	             	<h:outputLabel value="*" style="color : red;font-weight:bold;float:left;"/>
	             	<h:outputText value="Purpose" style="font-weight:bold;float:left;"/>
	             	<h:outputText value=":" style="font-weight:bold;float:left;" />
	             </h:panelGroup>
	             
	             <h:panelGroup>
	             	<h:inputHidden/>
	             	<h:outputText value="Remarks" style="font-weight:bold;float:left;"/>
	             	<h:outputText value=":" style="font-weight:bold;float:left;"/>
	             </h:panelGroup>
	             
	             <h:inputHidden/>
	             
	             
	             
	             <p:selectOneMenu value="#{raiseAssetRequestBean.editAssetDetails.assetType}" style="width: 160px;">
		              <f:selectItems value="#{raiseAssetRequestBean.assetsMap}" />
	             </p:selectOneMenu>
	             
	             
	             <p:calendar  pattern="dd-MMM-yyyy" value="#{raiseAssetRequestBean.editAssetDetails.requiredDate}" showButtonPanel="true" navigator="true" yearRange="c:c+10"/>
	             
	             
	             <p:calendar pattern="dd-MMM-yyyy" value="#{raiseAssetRequestBean.editAssetDetails.expectedReturnDate}" showButtonPanel="true" navigator="true" yearRange="c:c+10"/>
	              
	             
	             <p:selectOneMenu value="#{raiseAssetRequestBean.editAssetDetails.purpose}" style="width:100px;" >  
					<f:selectItems value="#{raiseAssetRequestBean.assetPurposeMap}" />   
	             </p:selectOneMenu>
	              
	             
	             <p:inputTextarea value="#{raiseAssetRequestBean.editAssetDetails.remarks}" rows="2" autoResize="false" />
	             
	             
	             <h:panelGroup>
	                <p:commandButton value="Add" action="#{raiseAssetRequestBean.addEditedAssetDetailsAction}" update="editDailogTable dialogGrid" style="width:62px;"/>                  
	                          
	             </h:panelGroup> 
           </h:panelGrid>
          <p:dataTable id="editDailogTable" value="#{raiseAssetRequestBean.editAssetDetailsList}" var="viewAssetDetails" binding="#{raiseAssetRequestBean.assetDetailsEditTable}">
		            
		            <p:column headerText="Asset Type"> 
		              	<h:outputText value="#{viewAssetDetails.assetType}" />                 
		            </p:column>  
		  
		            <p:column headerText="Required On"> 
		              	<h:outputText value="#{viewAssetDetails.requiredDate}" > 
		              		<f:convertDateTime pattern="dd-MMM-yyyy" timeZone="#{raiseAssetRequestBean.timeZone}"/>
		              	</h:outputText> 	               
		            </p:column>  
		            
		            <p:column headerText="Return Date"> 
		              	<h:outputText value="#{viewAssetDetails.expectedReturnDate}" >
		              		<f:convertDateTime pattern="dd-MMM-yyyy" timeZone="#{raiseAssetRequestBean.timeZone}"/>
		              	</h:outputText>                  
		            </p:column>  
		            
		            <p:column headerText="Purpose"> 
		              	<h:outputText value="#{viewAssetDetails.purpose}" />  	               
		            </p:column>  
		            
		            <p:column headerText="Remarks"> 
		              	<h:outputText value="#{viewAssetDetails.remarks}" />                 
		            </p:column>  
		            
		            <p:column headerText="Delete" style="text-align: center; width: 30px;">		
						<p:commandButton icon="ui-icon-close" title="Remove from list"
							actionListener="#{raiseAssetRequestBean.removeEditedAssetDetailsAction}" style="padding: 0" update="@form" />	
					</p:column> 
		          			       
          </p:dataTable>
        <h:panelGrid style="padding-top: 5px; width: 100%; border-top: 1px solid #d9d9d9"
						columnClasses="gridCellMiddleRightAligned">
			  <h:panelGroup>
		           <p:commandButton id="submit" value="Submit" update="@form"  actionListener="#{raiseAssetRequestBean.editConfirmationAction}"  />
		           <p:commandButton value="Close" onclick="assetEditDialog.hide()" type="button" /> 		           
	          </h:panelGroup>
		</h:panelGrid>
			</p:dialog>
			
		<p:confirmDialog widgetVar="editConfirmation" id="editConfirmation" severity="alert" message="Do you want to proceed?">
				<h:panelGroup style="text-align: right; float: right;">
					<p:commandButton value="Yes" action="#{raiseAssetRequestBean.saveEditedAssetRequestAction}" update="@form" oncomplete="editConfirmation.hide()"/>
					<p:commandButton  value="No" onclick="editConfirmation.hide()" type="button" />
				</h:panelGroup>
		</p:confirmDialog>	
	
		
		<p:confirmDialog widgetVar="confirmation" id="confirmation" severity="alert" message="Do you want to proceed?">
				<h:panelGroup style="text-align: right; float: right;">
					<p:commandButton value="Yes" action="#{raiseAssetRequestBean.saveAssetRequestAction}" update="@form" oncomplete="confirmation.hide()"/>
					<p:commandButton id="decline" value="No" onclick="confirmation.hide()" type="button" />
				</h:panelGroup>
		</p:confirmDialog>
		
		
         
     </h:form>
	</ui:define>
	
</ui:composition>
